/**
 */
;
(function(){
'use strict';
	
	var app = angular.module('fwa.mainApp');
	app.controller('WarningNoticeCtrl', ['$scope','$modal','$modalInstance','$http','$state', '$location','$stateParams','WarningAddService','BaseURL','Modal',
	    function ($scope,$modal,$modalInstance,$http,$state,$location,$stateParams,WarningAddService,baseUrl,Modal) {
		$scope.warningAddService=WarningAddService;
		if(!$scope.warningNotice){
			$scope.warningNotice = {}; 
		}else{
			$scope.warningNotice.date={};
			$scope.warningNotice.date.start=$scope.warningNotice.datestart;
			$scope.warningNotice.date.end=$scope.warningNotice.dateend;
		}
		  	   
//		 $scope.warningNotice.date = {};
//		initWarnNoticeDialog();
//		function initWarnNoticeDialog(){			
//			if(!!WarningAddService.warningNotice.name){
//				$scope.warningNotice.name=WarningAddService.warningNotice.name;
//				$scope.warningNotice.content=WarningAddService.warningNotice.content;
//				$scope.warningNotice.date.start=WarningAddService.warningNotice.datestart;
//				$scope.warningNotice.date.end=WarningAddService.warningNotice.dateend;
//				$scope.warningNotice.requirement=WarningAddService.warningNotice.requirement;				
//			}			
//		}				  	
 	    	 //关闭事件
			  $scope.onClose = function() {					
				 $modalInstance.dismiss();
			  }					  
			  //保存事件
			  $scope.warningNoticeDialog = function() {
				  if(!$scope.warningNotice.name)
					{
						Modal.alert("单位名称不能为空!");
						return;
					} 
				 
					if(!$scope.warningNotice.content)
					{
						Modal.alert("预警内容不能为空!");
						return;
					}
					
					if(!$scope.warningNotice.date.start)
					{
						Modal.alert("预警开始时段不能为空!");
						return;
					}
					if(!$scope.warningNotice.date.end)
					{
						Modal.alert("预警结束时段不能为空!");
						return;
					}
					if(!$scope.warningNotice.requirement)
					{
						Modal.alert("预警要求不能为空!");
						return;
					}
					var date=$scope.warningNotice.date;
					var param={
							name:$scope.warningNotice.name,
							content:$scope.warningNotice.content,
							datestart:date.start,
							dateend:date.end,
							requirement:$scope.warningNotice.requirement
					}
					$modalInstance.close(param);
			  }
			
	}]);
})();